package com.yao.netipro.test1;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.Transaction;

/**
 * @Author: yaoym
 * @Description: @TODO
 * @Date: Created in 16:17 2019/6/28
 * @Modified By:
 */
public class KillTask implements Runnable {
    @Override
    public void run() {
        Jedis jedis = new Jedis("192.168.1.32", 6379);
        jedis.select(0);

        int num = Integer.parseInt(jedis.get("kill_num"));

        if(num > 0 ){
            jedis.watch("kill_num", "kill_user");
            Transaction transaction = jedis.multi();
            transaction.decr("kill_num");
            transaction.rpush("kill_user", "9527");
            transaction.exec();
        }else{
            Demo1.pool.shutdown();
        }
        jedis.close();
    }
}
